package sixth;
class Person1{
    void print(){
        System.out.println("Person。。。");
    }
}
class Student1 extends Person1{
    public void print(){
        System.out.println("Student1.....");
    }
}
public class 方法的覆写 {
    public static void main(String[] args) {
        new Student1().print(); //此处执行的是被覆写之后的方法
    }
}
//如果被子类覆写的方法权限缩小的话 编译时会报错
/*
D:\WorkSpaces\Java\jdk-21\bin\java.exe "-javaagent:D:\Software\IntelliJ IDEA\IntelliJ IDEA 2023.3.2\lib\idea_rt.jar=62803:D:\Software\IntelliJ IDEA\IntelliJ IDEA 2023.3.2\bin" -Dfile.encoding=UTF-8 -Dsun.stdout.encoding=UTF-8 -Dsun.stderr.encoding=UTF-8 -classpath D:\WorkSpaces\JavaDevelopBase_start_329\out\production\JavaDevelopBase_start_329 sixth.方法的覆写
Student1.....

Process finished with exit code 0
 */
